#include <iostream>
#include <vector>

using namespace std;

int main()
{
    string s;
    cin >> s;
    bool f = false;

    vector<char> v;

    for (int i = 0; i < s.size(); i++) {
        if (s[i] == '(' || s[i] == '[' || s[i] == '{' || s[i] == '<') {
            v.push_back(s[i]);
        }
        else if (s[i] == ')') {
            if (s.size() != 0 && v.size() > 0) {
                int q = v[v.size() - 1];
                v.pop_back();
                if (q != '(') {
                    cout << "False";
                    f = true;
                    break;
                }
            }
            else {
                cout << "False";
                f = true;
                break;
            }
        }
        else if (s[i] == ']') {
            if (s.size() != 0 && v.size() > 0) {
                int q = v[v.size() - 1];
                v.pop_back();
                if (q != '[') {
                    cout << "False";
                    f = true;
                    break;
                }
            }
            else {
                cout << "False";
                f = true;
                break;
            }
        }
        else if (s[i] == '}') {
            if (s.size() != 0 && v.size() > 0) {
                int q = v[v.size() - 1];
                v.pop_back();
                if (q != '{') {
                    cout << "False";
                    f = true;
                    break;
                }
            }
            else {
                cout << "False";
                f = true;
                break;
            }
        }
        else if (s[i] == '>') {
            if (s.size() != 0 && v.size() > 0) {
                int q = v[v.size() - 1];
                v.pop_back();
                if (q != '<') {
                    cout << "False";
                    f = true;
                    break;
                }
            }
            else {
                cout << "False";
                f = true;
                break;
            }
        }
    }

    if (v.size() == 0 && f == false) {
        cout << "True";
    }
    else if (v.size() != 0 && f == false) {
        cout << "False";
    }

    return 0;
}
